home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Generators / E / code_locale.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  4.2 KB  |  129 lines

  1. /// Includes
  2. #define INTUI_V36_NAMES_ONLY
  3.  
  4. #include <exec/types.h>                 // exec
  5. #include <exec/lists.h>
  6. #include <exec/nodes.h>
  7. #include <dos/dos.h>                    // dos
  8. #include <dos/dostags.h>
  9. #include <clib/exec_protos.h>           // protos
  10. #include <clib/dos_protos.h>
  11. #include <pragmas/exec_pragmas.h>       // pragmas
  12. #include <pragmas/dos_pragmas.h>
  13.  
  14. #include <string.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <ctype.h>
  18.  
  19. #include "DEV_IE:Generators/defs.h"
  20. #include "DEV_IE:Include/IEditor.h"
  21. #include "DEV_IE:Generators/C/Protos.h"
  22. ///
  23.  
  24.  
  25. /// WriteLocale
  26. void WriteLocale( struct GenFiles *Files, struct IE_Data *IE )
  27. {
  28.     UWORD   cnt;
  29.  
  30.     FPrintf( Files->Std, "\nvoid SetupLocale( void )\n"
  31.              "{\n"
  32.              "\tUWORD\tcnt;\n\n"
  33.              "\tif( LocaleBase ) {\n"
  34.              "\t\tif( Catalog = OpenCatalog( NULL, \"%s.catalog\", OC_BuiltInLanguage, \"%s\", OC_Version, %ld, TAG_DONE )) {\n"
  35.              "\t\t\tfor( cnt = 0; cnt < ( sizeof( CatCompArray ) / sizeof( struct CatCompArrayType )); cnt++ )\n"
  36.              "\t\t\t\tCatCompArray[ cnt ].cca_Str = GetCatalogStr( Catalog, cnt, CatCompArray[ cnt ].cca_Str );\n"
  37.              "\t\t}\n"
  38.              "\t}\n",
  39.          IE->Locale->Catalog, IE->Locale->BuiltIn, IE->Locale->Version );
  40.  
  41.     struct ArrayNode *ar;
  42.     for( cnt = 0, ar = Files->Arrays.mlh_Head; ar->Next; ar = ar->Next, cnt++ )
  43.     FPrintf( Files->Std, "\n\tLocalizeArray( &%s[0] );", ar->Label );
  44.  
  45.     FPuts( Files->Std, "\n}\n"
  46.                "\n"
  47.                "void LocalizeArray( UBYTE **Array )\n"
  48.                "{\n"
  49.                "\twhile( *Array ) {\n"
  50.                "\t\t*Array = (UBYTE *)CatCompArray[ (ULONG)*Array ].cca_Str;\n"
  51.                "\t\t*Array++;\n"
  52.                "\t}\n"
  53.                "}\n"
  54.                "\n"
  55.                "void LocalizeTags( ULONG *Tags, UWORD Kind )\n"
  56.                "{\n"
  57.                "\tULONG\ttag;\n\t"
  58.                "\tswitch( Kind ) {\n"
  59.                "\t\tcase\tSTRING_KIND:\n"
  60.                "\t\t\t\ttag = GTST_String;\n"
  61.                "\t\t\t\tbreak;\n"
  62.                "\t\tcase\tTEXT_KIND:\n"
  63.                "\t\t\t\ttag = GTTX_Text;\n"
  64.                "\t\t\t\tbreak;\n"
  65.                "\t\tcase\tNUMBER_KIND:\n"
  66.                "\t\t\t\ttag = GTNM_Format;\n"
  67.                "\t\t\t\tbreak;\n"
  68.                "\t\tcase\tSLIDER_KIND:\n"
  69.                "\t\t\t\ttag = GTSL_LevelFormat;\n"
  70.                "\t\t\t\tbreak;\n"
  71.                "\t\tdefault:\n"
  72.                "\t\t\t\treturn;\n"
  73.                "\t\t\t\tbreak;\n"
  74.                "\t}\n"
  75.                "\twhile(( *Tags != tag ) && ( *Tags ))\n"
  76.                "\t\tTags++;\n"
  77.                "\tif( *Tags++ )\n"
  78.                "\t\t*Tags = (ULONG)CatCompArray[ *Tags ].cca_Str;\n\n"
  79.                "}\n"
  80.                "\n"
  81.                "void LocalizeList( struct MinList *List )\n"
  82.                "{\n"
  83.                "\tstruct Node\t*node;\n\n"
  84.                "\tfor( node = (struct Node *)List->mlh_Head; node->ln_Succ; node = node->ln_Succ )\n"
  85.                "\t\tnode->ln_Name = (char *)CatCompArray[ (ULONG)node->ln_Name ].cca_Str;\n"
  86.                "}\n"
  87.                "\n"
  88.                "void LocalizeGadgets( struct NewGadget *ng, ULONG *tags, UWORD *kinds, UWORD num )\n"
  89.                "{\n"
  90.                "\tUWORD\tcnt;\n\n"
  91.                "\tfor( cnt = 0; cnt < num; cnt++ ) {\n"
  92.                "\t\tif( ng->ng_GadgetText )\n"
  93.                "\t\t\tng->ng_GadgetText = CatCompArray[ (ULONG)ng->ng_GadgetText ].cca_Str;\n"
  94.                "\t\tLocalizeTags( tags, *kinds++ );\n"
  95.                "\t\twhile( *tags++ );\n"
  96.                "\t\tng++;\n"
  97.                "\t}\n"
  98.                "}\n"
  99.                "\n"
  100.                "void LocalizeMenus( struct NewMenu *menu )\n"
  101.                "{\n"
  102.                "\twhile( menu->nm_Type != NM_END ) {\n"
  103.                "\t\tif( menu->nm_Label != NM_BARLABEL )\n"
  104.                "\t\t\tmenu->nm_Label = (STRPTR)CatCompArray[ (ULONG)menu->nm_Label ].cca_Str;\n"
  105.                "\t\tif( menu->nm_CommKey )\n"
  106.                "\t\t\tmenu->nm_CommKey = (STRPTR)CatCompArray[ (ULONG)menu->nm_CommKey ].cca_Str;\n"
  107.                "\t\tmenu++;\n"
  108.                "\t}\n"
  109.                "}\n"
  110.                "\n"
  111.                "void LocalizeITexts( struct IntuiText *txt, UWORD cnt )\n"
  112.                "{\n"
  113.                "\twhile( cnt-- ) {\n"
  114.                "\t\ttxt->IText = (UBYTE *)CatCompArray[ (ULONG)txt->IText ].cca_Str;\n"
  115.                "\t\ttxt++;\n"
  116.                "\t}\n"
  117.                "}\n"
  118.                "\n"
  119.                "UBYTE GetActivationKey( STRPTR Text )\n"
  120.                "{\n"
  121.                "\twhile( *Text++ != '_' )\n"
  122.                "\t\tif( *Text == '\\0' )\n"
  123.                "\t\t\treturn( 0 );\n"
  124.                "\n\treturn( *Text );\n"
  125.                "}\n" );
  126. }
  127. ///
  128.  
  129.